int maxScore(int* cardPoints, int cardPointsSize, int k) {
    int total = 0;
    int rest_min = INT_MAX;
    int count = 0;
    int len = cardPointsSize - k;
    for (int i = 0; i < cardPointsSize; i++)
    {
        total += cardPoints[i];
    }
    if (!len)
    {
        return total;
    }
    for (int i = 0; i < cardPointsSize; i++)
    {
        count += cardPoints[i];
        if (i - len + 1 < 0)
        {
            continue;
        }
        if (rest_min > count)
        {
            rest_min = count;
        }
        count -= cardPoints[i - len + 1];
    }

    return total - rest_min;
}